package com.by.toolkit.enums;

import com.google.common.collect.Maps;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Map;

/**
 * @author Tian Wei
 * @version 1.0
 * @date 2024/1/5 6:41 PM
 */
@Getter
@AllArgsConstructor
public enum DingTalkEventCallbackEnum {

    CHECK_URL("check_url", "企业增加员工事件", DingTalkPartnerConst.CHECK_URL),
    ADD_ADDRESS_BOOK("user_add_org", "企业增加员工事件", DingTalkPartnerConst.ADDRESS_BOOK),
    UPDATE_ADDRESS_BOOK("user_modify_org", "通讯录用户更改", DingTalkPartnerConst.ADDRESS_BOOK),
    DEL_ADDRESS_BOOK("user_leave_org", "通讯录用户离职", DingTalkPartnerConst.ADDRESS_BOOK),
    ACTIVE_ADDRESS_BOOK("user_active_org", "加入企业后用户激活", DingTalkPartnerConst.ADDRESS_BOOK),
    DEPT_CREATE("org_dept_create", "通讯录企业部门创建", DingTalkPartnerConst.DEPT),
    DEPT_UPDATE("org_dept_modify", "通讯录企业部门修改", DingTalkPartnerConst.DEPT),
    DEPT_DELETED("org_dept_remove", "通讯录企业部门删除", DingTalkPartnerConst.DEPT),

    ;
    private final String eventType;
    private final String eventDesc;
    private final Integer eventCategory;
    public static final Map<String,Integer> MAP = Maps.newHashMap();

    static {
        for (DingTalkEventCallbackEnum value : DingTalkEventCallbackEnum.values()) {
            MAP.put(value.getEventType(),value.getEventCategory());
        }
    }

    public static Integer resolveEventCategoryByEventType(String eventType){
        return MAP.get(eventType);
    }

    public static class DingTalkPartnerConst{
        public static final int ADDRESS_BOOK = 1;//通讯录
        public static final int CHECK_URL = 2;//测试

        public static final int DEPT = 3;//部门事件变更

    }

}
